package com.zwy.controller;

import com.zwy.annotation.AccessLimit;
import com.zwy.domain.dto.UserRegisterDTO;
import com.zwy.domain.entity.User;
import com.zwy.domain.response.ResponseResult;
import com.zwy.domain.vo.UserAccountVO;
import com.zwy.service.UserService;
import com.zwy.utils.ControllerUtils;
import com.zwy.utils.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

/**
 * @author zwy
 * @version 1.0
 * @description: UserController
 * @date 2025/9/19 11:37
 */

@Tag(name = "用户相关接口")
@RequestMapping("/user")
@RestController
public class UserController
{
    @Resource
    private UserService userService;
    @Operation(summary = "获取当前登录用户信息")
    @AccessLimit(seconds = 60, maxCount = 30)
    @GetMapping("/auth/info")
    public ResponseResult<UserAccountVO> getInfo() {
        return ControllerUtils.messageHandler(() -> userService.findAccountById(SecurityUtils.getUserId()));
    }
    @Operation(summary = "用户注册")
    @AccessLimit(seconds = 60, maxCount = 30)
    @PostMapping("/register")
    public ResponseResult<Void> register(@RequestBody @Valid UserRegisterDTO userRegisterDTO){
        return userService.userRegister(userRegisterDTO);

    }

}
